package tg.app.rj.workticket;

import java.rmi.RemoteException;
import java.util.HashSet;

import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSet;
import psdi.mbo.MboValueInfo;
import psdi.util.MXException;

/****
 * 
 * @author pzx
 *
 */
public class Workticketline extends Mbo implements WorkticketlineRemote {
	
	private static HashSet skipFieldCopy = new HashSet();
	private static boolean isHashSetLoaded = false;
	
	public Workticketline(MboSet ms) throws MXException, RemoteException {
		super(ms);
	}

	public void add() throws MXException, RemoteException {
		super.add();
		setValue("SITEID", getInsertSite(), 11L);
		setValue("ORGID", getInsertOrganization(), 11L);
		MboRemote mboremote = super.getOwner();
		if (null != mboremote && "WT_DX".equals(mboremote.getName())) {
			super.setValue("wt_dxnum", mboremote.getString("wt_dxnum"), 11L);
			super.setValue("yorn1", "0", 11L);
			super.setValue("yorn2", "0", 11L);
			setValue("lineid", (int) getThisMboSet().max("lineid") + 1, 11L);
		} else if (null != mboremote) {
			super.setValue("wtnum", mboremote.getString("wtnum"), 11L);
			super.setValue("yorn1", "0", 11L);
			super.setValue("yorn2", "0", 11L);
			setValue("lineid", (int) getThisMboSet().max("lineid") + 1, 11L);
		}
	}
	
    protected boolean skipCopyField(MboValueInfo mbovalueinfo) throws RemoteException, MXException {
        if (!isHashSetLoaded){
            loadSkipFieldCopyHashSet();
        }
        return skipFieldCopy.contains(mbovalueinfo.getName());
    }

    private static void loadSkipFieldCopyHashSet() throws MXException,RemoteException {
		isHashSetLoaded = true;
		skipFieldCopy.add("ORGID");
		skipFieldCopy.add("SITEID");
		skipFieldCopy.add("WTNUM");
		skipFieldCopy.add("WT_DXNUM");
		skipFieldCopy.add("YORN1");
		skipFieldCopy.add("YORN2");
		skipFieldCopy.add("ISHISTORY");
		skipFieldCopy.add("WORKTICKETLINEID");
	}
			
	
}
